package com.h3c.nem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.h3c.nem.entity.OfferEmployeeinfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * (OfferEmployeeinfo)表数据库访问层
 *
 * @author makejava
 * @since 2022-06-22 19:20:51
 */
public interface OfferEmployeeinfoMapper extends BaseMapper<OfferEmployeeinfo> {

    @Select("SELECT offerid FROM Offer_EmployeeInfo GROUP BY offerid HAVING COUNT(1)>1")
    public List<String> queryRepeatEmployeeOfferIds();

    @Update(" delete from Offer_EmployeeInfo \n" +
            " where id != (SELECT a.id FROM (SELECT id FROM Offer_EmployeeInfo where offerid=#{offerId}  order by UpdateDate desc limit 1) AS a) \n" +
            " and offerid = #{offerId} ")
    public Integer deleteRepeatEmployeeRecords(@Param("offerId")String offerId);

//    @Select("SELECT b.* FROM Offer_Send_Detail a , Offer_EmployeeInfo b ,Offer_SocialSecurityAddress c \n" +
//            "WHERE a.id = b.offerid AND a.id=c.OfferId")
//    List<OfferEmployeeinfo> queryList();
}

